package com.suray.wcs.service.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.suray.basic.wcs.utils.IBaseEnum;

import java.io.Serializable;

public enum MachineTaskStatus implements IBaseEnum<Serializable> {
    /**
     * 任务等待下发
     */
    WAIT_SEND(1,"等待下发"),
    /**
     * 任务已下发
     */
    SENT(2,"已下发"),
    /**
     * agv任务执行完成
     */
    TASK_FINISH(3,"任务完成"),
    ;

    @EnumValue
    private int code;
    @JsonValue
    private String des;

    MachineTaskStatus(int code, String des) {
        this.code = code;
        this.des = des;
    }

    @Override
    public String toString() {
        return des;
    }

    @Override
    public Integer getValue() {
        return code;
    }

    public static MachineTaskStatus parseMachineTaskStatus(int machineTaskStatus) {
        MachineTaskStatus[] machineTaskPros = MachineTaskStatus.values();
        for (MachineTaskStatus taskStatus : machineTaskPros) {
            if (taskStatus.code == machineTaskStatus) {
                return taskStatus;
            }
        }
        throw new IllegalArgumentException("机械臂任务状态参数异常");
    }

    @Override
    public String getDescription() {
        return des;
    }

    @Override
    public Integer getVal(){
        return code;
    }
}
